<?php
(!defined('IN_TOA') || !defined('IN_ADMIN')) && exit('Access Denied!');
/*
	[天生创想] (C)2008-2011 515158 Inc.
	This is NOT a freeware, use is subject to license terms
    URL:http://www.515158.com/
*/

//if ( !is_superadmin() && !check_purview('manage_link') ) prompt('对不起，你没有权限执行本操作！');

empty($do) && $do = 'list';
if ($do == 'list') {

function get_ArticleSorts_list($fatherid=0,$selid=0,$layer=0)
{

    
    global $db;
	$query = $db->query("SELECT * FROM ".DB_TABLEPRE."city where father='$fatherid' ORDER BY id Asc  ");
	
	if(count($query)>0){
	   for($i=0;$i<$layer;$i++){
	   
	   $str.="<TD class=MemoTD width=20>&nbsp;</TD>";
	   
	   }
	echo '<TABLE id=D'.$fatherid.'s cellSpacing=0 cellPadding=0 border=0 width=100%><TR HEIGHT=22><TD class=noborder>'; 
	while ($row = $db->fetch_array($query)) {
	//$selstr = $row['id'] == $selid ? 'selected="selected"' : '';
	//$htmlstr= '<option value="'.$row['id'].'"  '.$selstr.'>'.$str.$row['title'].'</option>';
	$rsfno = $db->fetch_one_array("SELECT * FROM ".DB_TABLEPRE."city where father='".$row[id]."' ORDER BY id desc limit 0,1");
	if($rsfno[id]==''){
	$deletestr=' | <a href="admin.php?ac=index&fileurl=city&do=delete&id='.$row[id].'">删除</a>';
	}
	$htmlstr='<TABLE cellSpacing=0 cellPadding=0 border=0 width=100%>
<TR HEIGHT=22 onclick=D'.$row[id].'.click() id=D'.$row[id].'TR class=TableDetail2>
<TD class=MemoTD width=20>&nbsp;</TD>'.$str.'<TD class=MemoTD width=20><IMG class=outline id=D'.$row[id].' src="images/down.gif"></TD>
<TD class=MemoTD>'.$row[name].'</TD>
<TD width="100" align="right" class=MemoTD><a href="admin.php?ac=edit&do=edit&fileurl=city&id='.$row['id'].'">修改</a>'.$deletestr.'</TD></TR></TABLE>';
  
  
  
  
	echo $htmlstr;
	if($rsfno[id]!=''){
	get_ArticleSorts_list($row['id'],$selid,$layer+1);
	}
	}
    echo '</td></tr></table>';
	}
	
   return ;

}

	include_once('template/index.php');

} elseif ($do == 'delete') {
	$id = getGP('id','G','int');
	//foreach ($idarr as $id) {
	$db->query("DELETE FROM ".DB_TABLEPRE."city WHERE id = '$id'");
	//db->query("DELETE FROM ".DB_TABLEPRE."user_view WHERE uid = '$id'");
		
	//}
	goto_page('admin.php?ac=index&fileurl=city&message=1');

} 
?>